using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Viettel.VOFFICE.DAO.Models.Mapping
{
    public class v_SystemFunctionMap : EntityTypeConfiguration<v_SystemFunction>
    {
        public v_SystemFunctionMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(150);

            this.Property(t => t.ActionControllerName)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.Description)
                .HasMaxLength(200);

            this.Property(t => t.RolesName)
                .HasMaxLength(500);

            // Table & Column Mappings
            this.ToTable("v_SystemFunction");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.ActionControllerName).HasColumnName("ActionControllerName");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.RolesName).HasColumnName("RolesName");
            this.Property(t => t.IsActive).HasColumnName("IsActive");
            this.Property(t => t.ParentId).HasColumnName("ParentId");

            // Relationships
            this.HasOptional(t => t.v_SystemFunction2)
                .WithMany(t => t.v_SystemFunction1)
                .HasForeignKey(d => d.ParentId);

        }
    }
}
